package com.edu.bean;


import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class User implements ApplicationContextAware, DisposableBean, BeanNameAware, InitializingBean {
    private int userId;
    private String userName;
    private String userPass;
    private String BeanId;

    public String getBeanId() {
        return BeanId;
    }

    public void setBeanId(String beanId) {
        BeanId = beanId;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPass() {
        return userPass;
    }

    public void setUserPass(String userPass) {
        this.userPass = userPass;
    }

    public User() {
    }

    public User(int userId, String userName, String userPass) {
        this.userId = userId;
        this.userName = userName;
        this.userPass = userPass;
    }

    @Override
    public String toString() {
        return "User{" +
                "userId=" + userId +
                ", userName='" + userName + '\'' +
                ", userPass='" + userPass + '\'' +
                '}';
    }

    @Override
    public void setBeanName(String s) {
        System.out.println("spring容器执行了BeanNameAware接口的方法");
    }


    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("执行了  ApplicationContextAware接口的方法");
    }

    public void init(){
        System.out.println("执行了init方法");
        this.userId = 2;
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("执行了接口销毁方法");
    }

    public void MyDestroy(){
        System.out.println("执行了自定义销毁方法");
    }

    public void sayHi(){
        System.out.println("执行了一些自身的业务方法");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("执行了InitializingBean接口方法");
    }

}
